﻿namespace ChinaUnicom.Models
{
    using System.ComponentModel;

    public class Account : INotifyPropertyChanged
    {
        public const string MobileDefault = "default-mobile";

        public Account()
        {
            mobile = MobileDefault;
            password = string.Empty;
        }

        string client;

        public string ClientName
        {
            get { return client; }
            set
            {
                if (value != client)
                {
                    client = value;
                    NotifyPropertyChanged("ClientName");
                }
            }
        }

        string password;

        public string Password
        {
            get { return password; }
            set
            {
                if (value != password)
                {
                    password = value;
                    NotifyPropertyChanged("Password");
                }
            }
        }

        string mobile;

        public string Mobile
        {
            get { return mobile; }
            set
            {
                if (value != this.mobile)
                {
                    this.mobile = value;
                    NotifyPropertyChanged("Mobile");
                }
            }
        }
        
        public override string ToString()
        {
            return string.Format("{{{0} : {1}}}", client, mobile);
        }

        public event PropertyChangedEventHandler PropertyChanged;

        void NotifyPropertyChanged(string property)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(property));
            }
        }
    }
}
